/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Modelo;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ChArFaTo
 */
@Entity
@Table(name = "usuario", catalog = "proyectosw", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "UsuarioEJB.findAll", query = "SELECT u FROM UsuarioEJB u"),
    @NamedQuery(name = "UsuarioEJB.findByUId", query = "SELECT u FROM UsuarioEJB u WHERE u.uId = :uId"),
    @NamedQuery(name = "UsuarioEJB.findByUCorreoUsuario", query = "SELECT u FROM UsuarioEJB u WHERE u.uCorreoUsuario = :uCorreoUsuario"),
    @NamedQuery(name = "UsuarioEJB.findByUPassword", query = "SELECT u FROM UsuarioEJB u WHERE u.uPassword = :uPassword"),
    @NamedQuery(name = "UsuarioEJB.findByUNombreCuenta", query = "SELECT u FROM UsuarioEJB u WHERE u.uNombreCuenta = :uNombreCuenta")})
public class UsuarioEJB implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(nullable = false)
    private Integer uId;
    @Size(max = 255)
    @Column(length = 255)
    private String uCorreoUsuario;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(nullable = false, length = 20)
    private String uPassword;
    @Size(max = 255)
    @Column(length = 255)
    private String uNombreCuenta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usuarioEJB")
    private Collection<UsuarioUtipousuarioEJB> usuarioUtipousuarioEJBCollection;
    @OneToMany(mappedBy = "usuarioUId")
    private Collection<PersonaEJB> personaEJBCollection;

    public UsuarioEJB() {
    }

    public UsuarioEJB(Integer uId) {
        this.uId = uId;
    }

    public UsuarioEJB(Integer uId, String uPassword) {
        this.uId = uId;
        this.uPassword = uPassword;
    }

    public Integer getUId() {
        return uId;
    }

    public void setUId(Integer uId) {
        this.uId = uId;
    }

    public String getUCorreoUsuario() {
        return uCorreoUsuario;
    }

    public void setUCorreoUsuario(String uCorreoUsuario) {
        this.uCorreoUsuario = uCorreoUsuario;
    }

    public String getUPassword() {
        return uPassword;
    }

    public void setUPassword(String uPassword) {
        this.uPassword = uPassword;
    }

    public String getUNombreCuenta() {
        return uNombreCuenta;
    }

    public void setUNombreCuenta(String uNombreCuenta) {
        this.uNombreCuenta = uNombreCuenta;
    }

    @XmlTransient
    public Collection<UsuarioUtipousuarioEJB> getUsuarioUtipousuarioEJBCollection() {
        return usuarioUtipousuarioEJBCollection;
    }

    public void setUsuarioUtipousuarioEJBCollection(Collection<UsuarioUtipousuarioEJB> usuarioUtipousuarioEJBCollection) {
        this.usuarioUtipousuarioEJBCollection = usuarioUtipousuarioEJBCollection;
    }

    @XmlTransient
    public Collection<PersonaEJB> getPersonaEJBCollection() {
        return personaEJBCollection;
    }

    public void setPersonaEJBCollection(Collection<PersonaEJB> personaEJBCollection) {
        this.personaEJBCollection = personaEJBCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (uId != null ? uId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UsuarioEJB)) {
            return false;
        }
        UsuarioEJB other = (UsuarioEJB) object;
        if ((this.uId == null && other.uId != null) || (this.uId != null && !this.uId.equals(other.uId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Modelo.UsuarioEJB[ uId=" + uId + " ]";
    }
    
}
